package com.huxiu;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.huxiu.base.ZiXunDetailPager;
import com.huxiu.lib.PagerScreenTab;
import com.huxiu.pagers.commment.HotComment;
import com.huxiu.pagers.commment.NewComment;
import com.huxiu.pagers.message.PersionMessage;
import com.huxiu.pagers.message.SystemMessage;
import com.huxiu.utils.Constants;
import com.huxiu.utils.Settings;
import com.huxiu.utils.Utils;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;
import com.umeng.analytics.MobclickAgent;


public class MessageActivity extends BaseActivity{
    @ViewInject(R.id.indicator)
    private PagerScreenTab indicator;
    @ViewInject(R.id.pager)
    private ViewPager viewpager;

    private MessageActivity instance;


    @ViewInject(R.id.layout_back)
    private RelativeLayout layout_back;

    @ViewInject(R.id.layout_wirte)
    private RelativeLayout layout_wirte;




    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_message);
        instance = this;
        ViewUtils.inject(this);
        viewpager.setAdapter(new MyAdapter());
        // 让指针控件绑定ViewPager
        indicator.setViewPager(viewpager);
    }

    String[] s = {"系统消息", "私信"};


    class MyAdapter extends PagerAdapter {
        // 返回标题
        @Override
        public CharSequence getPageTitle(int position) {
            return s[position];
        }

        @Override
        public int getCount() {
            return s.length;
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }

        private ZiXunDetailPager pager;

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            switch (position) {
                case 0:
                    pager = new SystemMessage(instance);
                    container.addView(pager.rootView);
                    // 更新数据
                    pager.initData();
                    break;
                case 1:
                    pager = new PersionMessage(instance);
                    container.addView(pager.rootView);
                    // 更新数据
                    pager.initData();
                    break;
            }

            return pager.rootView;
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            container.removeView((View) object);
        }

    }


    @OnClick({R.id.layout_back,R.id.layout_wirte})
    public void mOnClick(View v){
        switch (v.getId()){
            case R.id.layout_back:
                instance.finish();
                break;
            case R.id.layout_wirte:
                break;
        }
    }


    @Override
    public void onResume() {
        super.onResume();
        MobclickAgent.onPageStart("SplashScreen");
        MobclickAgent.onResume(this);
    }
    @Override
    public void onPause() {
        super.onPause();
        MobclickAgent.onPageEnd("SplashScreen");
        MobclickAgent.onPause(this);
    }





}
